<%@ Control CodeBehind="ListView.ascx.cs" Language="c#" Inherits="SplendidCRM.Contacts.ListView" AutoEventWireup="True" %>
<script runat="server">
/**********************************************************************************************************************
 * SplendidCRM is a Customer Relationship Management program created by SplendidCRM Software, Inc. 
 * Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved.
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU Affero General Public License as published by the Free Software Foundation, either version 3 
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with this program. 
 * If not, see <http://www.gnu.org/licenses/>. 
 * 
 * You can contact SplendidCRM Software, Inc. at email address support@splendidcrm.com. 
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 
 * the Appropriate Legal Notices must display the following words on all interactive user interfaces: 
 * "Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved."
 *********************************************************************************************************************/
</script>
<div id="divListView">
	<%@ Register TagPrefix="SplendidCRM" Tagname="ModuleHeader" Src="~/_controls/ModuleHeader.ascx" %>
	<SplendidCRM:ModuleHeader ID="ctlModuleHeader" Module="Contacts" Title=".moduleList.Home" EnablePrint="true" HelpName="index" EnableHelp="true" Runat="Server" />
	<%@ Register TagPrefix="SplendidCRM" Tagname="SearchView" Src="~/_controls/SearchView.ascx" %>
	<SplendidCRM:SearchView ID="ctlSearchView" Module="Contacts" ShowDuplicateSearch="true" Visible="<%# !PrintView %>" Runat="Server" />
	<%@ Register TagPrefix="SplendidCRM" Tagname="ExportHeader" Src="~/_controls/ExportHeader.ascx" %>
	<SplendidCRM:ExportHeader ID="ctlExportHeader" Module="Contacts" Title="Contacts.LBL_LIST_FORM_TITLE" Runat="Server" />
	
    <script type="text/javascript">
        function SaveCheckedColumnValue() {
            var result = [];
            $('[type="CheckedColumnItem"]').each(function () {
                var name = $(this).attr("col");
                var sign = $(this).find('.cboSign').first().val();
                var text = $(this).find('.txtValue').first().val();
                result.push(name + "|" + sign + "|" + text);
            });
            $('#<%=cltHiddenCheckedColumnValue.ClientID %>').val(result.join(","));
        }
    </script>
    <asp:UpdatePanel ID="cltFilterUpdatePanel" runat="server" UpdateMode="Always">
    <ContentTemplate>
        <asp:HiddenField ID="cltHiddenCheckedColumnValue" runat="server" />
        <table border="0">
            <tr>
                <td>
                    <asp:ListBox runat="server" EnableViewState="true" ID="cltSearchColumnList" Width="150px" Height="200px"></asp:ListBox>
                </td>
                <td>
                    <asp:Button ID="cltAddFilterColumn" Text=">>" runat="server" OnClick="cltAddFilterColumn_OnClick" OnClientClick="SaveCheckedColumnValue();" />
                </td>
                <td>
                    <asp:Repeater runat="server" ID="cltCheckedColumnRepeater" EnableViewState="true" OnItemCommand="cltCheckedColumnRepeater_OnItemCommand" OnItemDataBound="cltCheckedColumnRepeater_OnItemDataBound">
                    <ItemTemplate>
                        <div type="CheckedColumnItem" col='<%#Eval("NAME") %>'>
                            <asp:Label runat="server" Text='<%#Eval("DISPLAY_NAME") %>' Width="150px" />
                            <asp:DropDownList runat="server" CssClass="cboSign">
                                <asp:ListItem Value="Equal" Text="Equal to" Enabled="true"></asp:ListItem>
                                <asp:ListItem Value="NotEqual" Text="Not equal to"></asp:ListItem>
                                <asp:ListItem Value="GreaterThan" Text="Greater than"></asp:ListItem>
                                <asp:ListItem Value="LessThan" Text="Less than"></asp:ListItem>
                                <asp:ListItem Value="NotGreaterThan" Text="Not greater than"></asp:ListItem>
                                <asp:ListItem Value="NotLessThan" Text="Not less than"></asp:ListItem>
                            </asp:DropDownList>
                            <asp:TextBox runat="server" Width="75px" CssClass="txtValue"/>
                            <asp:Button runat="server" CssClass="button" Text="Remove" CommandName="RemoveColumn" CommandArgument='<%#Eval("NAME") %>' OnClientClick="SaveCheckedColumnValue();" />
                        </div>
                    </ItemTemplate>
                    </asp:Repeater>
                </td>
            </tr>
        </table>
    </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Button ID="cltFilterButton" CssClass="button" runat="server" Text="Filter" OnClientClick="SaveCheckedColumnValue();" OnClick="cltFilterButton_OnClick" />

    <div>
        <asp:Label runat="server" Text="Choose campaign: " />
        <asp:DropDownList ID="cltCampaignList" runat="server" />
        <asp:Button ID="cltImportToCampaign" CssClass="button" runat="server" Text="Import selected to campaign" OnClick="cltImportToCampaign_OnClick" />
        <asp:CheckBox runat="server" Text="Overwrite existed" ID="cltOverWriteCampaignContact"/>
        <asp:HyperLink ID="cltLinkToCampaign" Visible="false" runat="server" Text="Go to campaign" />
    </div>

	<asp:Panel CssClass="button-panel" Visible="<%# !PrintView %>" runat="server">
		<asp:Label ID="lblError" CssClass="error" EnableViewState="false" Runat="server" />
	</asp:Panel>
	
	<asp:HiddenField ID="LAYOUT_LIST_VIEW" Runat="server" />
	<SplendidCRM:SplendidGrid id="grdMain" OnPageIndexChanged="grdMain_OnPageIndexChanged" SkinID="grdListView" AllowPaging="<%# !PrintView %>" EnableViewState="true" runat="server">
		<Columns>
			<asp:TemplateColumn HeaderText="" ItemStyle-Width="1%">
				<ItemTemplate><%# grdMain.InputCheckbox(!PrintView && !IsMobile && SplendidCRM.Crm.Modules.MassUpdate(m_sMODULE), ctlCheckAll.FieldName, Sql.ToGuid(Eval("ID")), ctlCheckAll.SelectedItems) %></ItemTemplate>
			</asp:TemplateColumn>
			<asp:TemplateColumn HeaderText="" ItemStyle-Width="1%" ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="false">
				<ItemTemplate>
					<asp:HyperLink Visible='<%# SplendidCRM.Security.GetUserAccess(m_sMODULE, "edit", Sql.ToGuid(Eval("ASSIGNED_USER_ID"))) >= 0 %>' NavigateUrl='<%# "~/" + m_sMODULE + "/edit.aspx?id=" + Eval("ID") %>' ToolTip='<%# L10n.Term(".LNK_EDIT") %>' Runat="server">
						<asp:Image SkinID="edit_inline" Runat="server" />
					</asp:HyperLink>
				</ItemTemplate>
			</asp:TemplateColumn>
		</Columns>
	</SplendidCRM:SplendidGrid>
	<%@ Register TagPrefix="SplendidCRM" Tagname="CheckAll" Src="~/_controls/CheckAll.ascx" %>
	<SplendidCRM:CheckAll ID="ctlCheckAll" Visible="<%# !PrintView && !IsMobile && SplendidCRM.Crm.Modules.MassUpdate(m_sMODULE) %>" Runat="Server" />
	<%@ Register TagPrefix="SplendidCRM" Tagname="MassUpdate" Src="MassUpdate.ascx" %>
	<SplendidCRM:MassUpdate ID="ctlMassUpdate" Visible="<%# !PrintView && !IsMobile && SplendidCRM.Crm.Modules.MassUpdate(m_sMODULE) %>" Runat="Server" />

	<%@ Register TagPrefix="SplendidCRM" Tagname="DumpSQL" Src="~/_controls/DumpSQL.ascx" %>
	<SplendidCRM:DumpSQL ID="ctlDumpSQL" Visible="<%# !PrintView %>" Runat="Server" />
</div>


